<#include "/resources/share/common/_commtop.html"/>
<@layout>
<head>
<title>发帖子</title>
<link rel="stylesheet" type="text/css" href="${contextPath}/resources/framework/summernote/summernote.css"></link>
<script type="text/javascript" src="${contextPath}/resources/framework/summernote/summernote.min.js"></script>
<script type="text/javascript" src="${contextPath}/resources/framework/summernote/lang/summernote-zh-CN.js"></script>
</head>

<div class="row clearfix">
<div class="col-md-12 column">
<form action="${contextPath}/section/update/${section.id}" method="post" enctype="multipart/form-data">
<input type="file" id="contextFile" onchange="readFile(this)" style="display: none"/>
<input type="hidden" id="sectionImg" name="section.section_img" value="" /> 
<input type="hidden" name="section.context" id="SummernoteCode"/>
帖子形象：
<img id="sectionImgSrc"
	src="${section.section_img}"
	onclick="getFileUpload();" style="width: 50px; height: 50px;" />
标题:<input type="text" name="section.name" value="${section.name}"/>${nameMsg}
<div style="height: 15px;"></div>
<div id="summernote">在此输入帖子内容</div>
</br>
${contextMsg}
 <script>
    $(document).ready(function() {
        $('#summernote').summernote();
    });

    $('#summernote').summernote({
    	  lang: 'zh-CN',
    	  //height: 300,                 // set editor height
    	  minHeight: 300,             // set minimum height of editor
    	  maxHeight: null,             // set maximum height of editor
    	  focus: false                  // set focus to editable area after initializing summernote
    	}); 
	
	function getCode(){
		var markupStr = $('#summernote').summernote('code');
		document.getElementById("SummernoteCode").value = markupStr;
	}
	function setCode(markupStr){
		$('#summernote').summernote('code', markupStr);
	}
	setCode('${section.context}');
	
	function readFile(obj) {
		var file = obj.files[0];
		//判断类型是不是图片  
		if(!/image\/\w+/.test(file.type)) {
			alert("请确保文件为图像类型");
			return false;
		}
		//上次修改时间  
		//alert(file.lastModifiedDate); 
			//名称  
		//alert(file.name); 
		//大小 字节  
		var fsize = file.size; 
		//判断文件大小
		if(fsize/1024 >3000){
			alert("上传图片大小不能大于3M");
			return false;
		}
		var reader = new FileReader();
		reader.readAsDataURL(file);
		reader.onload = function(e) { 
			document.getElementById("sectionImg").value=this.result;
			document.getElementById("sectionImgSrc").src = this.result;
		}
	}
function getFileUpload(){
document.getElementById("contextFile").click();
}
  </script>
  
  <div class="form-group">
  <label for="userNo" class="col-sm-2 control-label">验证码</label>
	<div class="col-sm-10">
		<img src="${contextPath}/common/captcha" onclick="getcaptcha(this);"/>
	</div>
  </div>
  <div class="form-group">
		<div class="col-xs-12  ">
			<div class="input-group">
			<input type="text" id="captcha" name="captcha" 
				    class="form-control" 
			    	placeholder="验证码" style="width: 400px;"/>
			<label for="inputPassword" class="control-label" name="password">${codeMsg}</label>
			</div>
		</div>
    </div>
  
  <div class="form-group">
					<div class="col-sm-offset-2 col-sm-10">
						 <button type="submit" class="btn btn-default" onclick="getCode();">确认</button>
					</div>
  </div>
   <script type="text/javascript">
  function getcaptcha(obj){
	  var nowtime = new Date();
	  obj.src="${contextPath}/common/captcha/"+nowtime;
	}
  
  </script> 
</form>
</div>
</div>
<div style="height: 30px;"></div>
<#include "/resources/share/common/_friendshiplink.html" />
<@pagelink />
</@layout>
